package com.atguigu.service.impl;

import com.atguigu.bean.User;
import com.atguigu.dao.UserDao;
import com.atguigu.dao.impl.UserDaoImpl;
import com.atguigu.service.UserService;

/**
 * @Author zhangchunsheng
 * @CreateTime: 2025/01/08
 */
public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDaoImpl();

    @Override
    public User login(User user) {
        try {
            return userDao.selectUserByUsernameAndPassword(user);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void register(User user) {
        try {
            userDao.insertUser(user);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void updatePwd(User user) {
        try {
            userDao.updatePwd(user);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }


}
